package com.example.zydraw;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.zydraw.draw.LineDrawPolicy;
import com.example.zydraw.view.DiyDrawView;

public class MainActivity extends AppCompatActivity implements CreateNewDialogFragment.UpdateListener {

    DiyDrawView diyDrawView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        initView();
    }

    private final LineDrawPolicy lineDrawPolicy = new LineDrawPolicy();

    private void initView() {
        findViewById(R.id.edit_paint).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //new EditPaintDialogFragment().show(getSupportFragmentManager(), "EditPaintDialogFragment");
                new CreateNewDialogFragment(lineDrawPolicy, MainActivity.this).show(getSupportFragmentManager(), "CreateNewDialogFragment");
            }
        });

        diyDrawView = findViewById(R.id.diy_draw);
        diyDrawView.setDrawPolicy(lineDrawPolicy);
    }

    @Override
    public void update() {
        diyDrawView.invalidate();
    }
}